//
//  SEGPhoneRechargeConfirmView.m
//  ExcellentHome
//
//  Created by 揭婧雯 on 2017/2/28.
//  Copyright © 2017年 陈区. All rights reserved.
//

#import "SEGPhoneRechargeConfirmView.h"

@implementation SEGPhoneRechargeConfirmView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self customUI];
    }
    return self;
}

#pragma mark - 初始化界面

- (void)customUI
{
    self.backgroundColor = kColor_bg3;
    
    //白色背景视图
    self.contentView = [[UIView alloc] init];
    self.contentView.backgroundColor = kColor_W;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = 5;
    [self addSubview:self.contentView];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(270);
    }];

    //标题
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.text = @"你输入的手机号码为";
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.titleLabel.textColor = kColor_1;
    self.titleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.top.equalTo(self.contentView).with.offset(29);
    }];
    
    //号码
    self.phoneLabel = [[UILabel alloc] init];
//    self.phoneLabel.text = @"18800001111";
    self.phoneLabel.font = [UIFont systemFontOfSize:24];
    self.phoneLabel.textColor = kColor_T;
    self.phoneLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.phoneLabel];
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(8);
        make.height.mas_equalTo(24);
    }];
    
    //注意
    self.descLabel = [[UILabel alloc] init];
    self.descLabel.text = @"注意：务必确保提交的手机号码无误，\n否则话费无法到账。";
    self.descLabel.font = [UIFont systemFontOfSize:13];
    self.descLabel.textColor = kColor_3;
    self.descLabel.numberOfLines = 2;
    self.descLabel.backgroundColor = [UIColor clearColor];
    self.descLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.descLabel];
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.top.equalTo(self.phoneLabel.mas_bottom).with.offset(13);
    }];
    
    //返回按钮
    self.gobackButton = [[UIButton alloc] init];
    self.gobackButton.backgroundColor = [UIColor clearColor];
    [self.gobackButton setTitle:@"返回修改" forState:UIControlStateNormal];
    [self.gobackButton setTitleColor:kColor_1 forState:UIControlStateNormal];
    self.gobackButton.titleLabel.font = [UIFont systemFontOfSize:16];
    self.gobackButton.layer.borderWidth = 0.5;
    self.gobackButton.layer.borderColor = kColor_L2.CGColor;
    [self.gobackButton addTarget:self action:@selector(gobackButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.gobackButton];
    [self.gobackButton mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.descLabel.mas_bottom).with.offset(14);
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_centerX);
        make.height.mas_equalTo(44);
    }];
    
    //确认按钮
    self.confirmButton = [[UIButton alloc] init];
    self.confirmButton.backgroundColor = [UIColor clearColor];
    [self.confirmButton setTitle:@"确认" forState:UIControlStateNormal];
    [self.confirmButton setTitleColor:kColor_T forState:UIControlStateNormal];
    self.confirmButton.titleLabel.font = [UIFont systemFontOfSize:16];
    self.confirmButton.layer.borderWidth = 0.5;
    self.confirmButton.layer.borderColor = kColor_L2.CGColor;
    [self.confirmButton addTarget:self action:@selector(confirmButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.confirmButton];
    [self.confirmButton mas_makeConstraints:^(MASConstraintMaker* make) {
        make.top.equalTo(self.descLabel.mas_bottom).with.offset(14);
        make.left.equalTo(self.contentView.mas_centerX);
        make.right.equalTo(self.contentView.mas_right);
        make.height.mas_equalTo(44);
        make.bottom.mas_equalTo(self.contentView);
    }];
}

- (void)gobackButtonClick:(UIButton*)sender
{
    self.hidden = YES;
}

- (void)confirmButtonClick:(UIButton*)sender
{
    if (self.viewDelegate && [self.viewDelegate respondsToSelector:@selector(confirmPhoneNumber)]) {
        [self.viewDelegate confirmPhoneNumber];
    }
    self.hidden = YES;
}
@end
